//
// Created by 86131 on 2023/9/24.
//
using namespace std;
//#define MaxSize1 = 10
#include <iostream>
typedef int Position;
typedef int ElementType;
typedef struct QNode * PtrToNode;
struct QNode {
    ElementType * Data;//存元素的数组
    Position Front,Rear;//队列的头指针尾指针
    int MaxSize;//队列最大容量
};
typedef PtrToNode Queue;
<<<<<<< HEAD
//00
=======
//
>>>>>>> origin/master
Queue CreateQueue(int MaxSize)
{
    Queue Q = (Queue)malloc(sizeof(struct QNode));
    Q->Data = (ElementType *)malloc(MaxSize);
    Q->Front = Q->Rear = 0;
    Q->MaxSize = MaxSize;
    return Q;
}
bool IsFull(Queue Q){
    return ((Q->Rear+1)%Q->MaxSize ==Q->Front);//用来判断队列是否满了
}
bool AddQ(Queue Q,ElementType X){//入队函数
    if(IsFull(Q)){
        cout<<"队列满";
        return false;
    }
    else {
        Q->Rear = (Q->Rear+1)%Q->MaxSize;//尾指针移向下一个位置
<<<<<<< HEAD
        
=======
>>>>>>> origin/master
        Q->Data[Q->Rear] = X;
        return true;
    }
}
bool IsEmpty(Queue Q){//判断队列是否为空
    return (Q->Rear==Q->Front);
}
ElementType DeleteQ(Queue Q){
    if(IsEmpty(Q)){
        cout<<"队列空";
        return 0;
    }
    else{
        Q->Front = (Q->Front+1)%Q->MaxSize;//删除队首元素
        return Q->Data[Q->Front];
    }
};